import java.util.Scanner;

//4.	根据用户不同的选择计算不同形状的面积
public class D11 {
	public static void main(String[] args) {
		System.out.println("请选择要计算哪种形态的面积：" + "\n 1、正方形  \n 2、长方形 \n 3、三角形 \n 4、圆形");
		Scanner cc = new Scanner(System.in);
		int x = cc.nextInt();
		switch (x) {
		case 1:
			System.out.println("请输入正方形的边长：");
			double zNum = cc.nextDouble();
			System.out.println("该正方形的面积是："+getZFX(zNum));
			break;
		case 2:
			System.out.println("请分别输入长方形的长和宽：");
			double cChang = cc.nextDouble();
			double cKuan = cc.nextDouble();
			System.out.println("该长方形的面积是："+getCFX(cChang,cKuan));
			break;
		case 3:
			System.out.println("请分别输入三角形的底和高：");
			double sDi = cc.nextDouble();
			double sGao = cc.nextDouble();
			System.out.println("该三角形的面积是："+getSJX(sDi,sGao));
			break;
		case 4:
			System.out.println("请输入圆的半径：");
			double yBanJin = cc.nextDouble();
			System.out.println("该圆的面积是："+getYuan(yBanJin));
			break;
		default:
			System.out.println("选择错误！");
		}
	}

	// 求正方形面积
	public static double getZFX(double a) {
		return a * a;
	}

	// 求长方形面积
	public static double getCFX(double a, double b) {
		return a * b;
	}

	// 求圆面积
	public static double getYuan(double r) {
		return 3.14 * r * r;
	}

	// 求三角面积
	public static double getSJX(double a, double b) {
		return a * b / 2;
	}
}
